<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta charset="utf-8" />
		<script type="text/javascript" src="${pageContext.request.contextPath}/static/lib/jquery-1.11.1.min.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/static/lib/jquery.metadata.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/static/lib/jquery.validate.min.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/static/lib/ajaxfileupload.js"></script>
		<title>用户列表</title>
		
		<script>
			$(function(){
				$(".deleteLink").each(function(){
			 		   $(this).click(function(){
			 			  if(confirm("确定要删除吗？")){
			 			  }else{
			 				  $(this).attr("href","");
			 			  }
			  		  })
			    });
				
				$("#uploadFile").ace_file_input({
					style:'well',
					btn_choose:'Drop files here or click to choose',
					btn_change:null,
					no_icon:'ace-icon fa fa-cloud-upload',
					droppable:true,
					thumbnail:'small', //large | fit
					preview_error: function(fileName, error_code){
					}
				}).on('change', function(){
					//console.log($(this).data('ace_input_files'));
					//console.log($(this).data('ace_input_method'));
				});
				
				$("#subjectStudentSaveBtn").on('click', function(){
					$.ajaxFileUpload({
						url: '${contextPath}/OnlineExam/uploadFile',
						secureuri: false,
						fileElementId: 'uploadFile',  //$("form").serialize();
						dataType: 'json',
						complete: function(data){
							
						},
						success: function(data, status){
							if(data.success){
								window.location.reload();
								alert('添加成功');
							}else{
								alert(data.messageMap.message);
							}
						},
						error: function(data, status, e){
							window.location.reload();
							alert("添加成功");
						}
					});
				});
				
			});
		</script>
	</head>

	<body class="no-skin">
		<!-- /section:basics/sidebar -->
								<div class="row">
<div id="messageDiv">
<c:if test="${not empty message}">
		<script>
			alert('${message}');
		</script>
</c:if>
</div>
									<div class="col-xs-12">
										<a class="btn btn-xs btn-primary" href="add">
										<i class="ace-icon fa fa-plus"></i><span style="font-size:16px">添加学生信息</span>
										</a>
										<a class="btn btn-xs btn-primary" id="batchAddStudentBtn" data-toggle="modal" data-target="#uploadFileModal">
										<i class="ace-icon fa fa-plus"></i><span style="font-size:16px">批量添加学生信息</span>
										</a>
										<table id="sample-table-1" class="table table-striped table-bordered table-hover">
											<thead>
			<%-- <tr>
				<td><a href="changeLocale?localType=en_US"><spring:message code="page.index.english" /></a></td>
				<td><a href="changeLocale?localType=zh_CN"><spring:message code="page.index.chinese" /></a></td>
				<td colspan="6"></td>
			</tr>
												<tr>
													<th class="center">
														<label class="position-relative">
															<a href="add">
																<button class="btn btn-xs btn-success">
																	<i class="ace-icon fa fa-plus bigger-120"></i>
																</button>
															</a>
														</label>
													</th>
													<th><spring:message code="user.id.message"/></th>
													<th class="hidden-480"><spring:message code="user.name.message"/></th>
													<th class="hidden-480"><spring:message code="user.gender.message"/></th>
													<th class="hidden-480"><spring:message code="user.birthday.message"/></th>
													<th class="hidden-480"><spring:message code="user.tel.message"/></th>
													<th class="hidden-480"><spring:message code="user.address.message"/></th>
													<th><spring:message code="user.action.message"/></th>
												</tr> --%>
												<tr>
													<th>学号</th>
													<th>姓名</th>
													<th>性别</th>
													<th>联系电话</th>
													<th>电子邮箱</th>
													<th>联系地址</th>
													<th>出生日期</th>
													<th>操作</th>
												</tr>
											</thead>

											<tbody>
											<c:forEach items="${pageList.dates}" var="user">
												<tr>
													<!-- <td class="center">
														<label class="position-relative">
															<input type="checkbox" class="ace" />
															<span class="lbl"></span>
														</label>
													</td> -->

													<td>${user.userId}</td>
													<td>${user.userName}</td>
													<td class="hidden-480">${user.gender }</td>
													<td>${user.tel}</td>
													<td>${user.email}</td>
													<td>${user.address}</td>
													<td>${user.birthday}</td>
													<td>
														<a title="修改" href="edit/${user.userId }" class="btn btn-xs btn-primary">
															<i class="ace-icon fa fa-pencil bigger-120"></i>
														</a>
														<a title="删除" href="delete/${user.userId }" class="btn btn-xs btn-primary deleteLink" >
															<i class="ace-icon fa fa-trash-o bigger-120"></i>
														</a>
													</td>
												</tr>
												</c:forEach>
												<tr><td  colspan="8">
													<jsp:include page="/pager.jsp">
													<jsp:param name="url" value="${pageContext.request.contextPath}/user"/>  
													<jsp:param name="items" value="${pageList.totalSize}"/> 
													<jsp:param name="pageSize" value="${pageList.pageSize}"/>  
													</jsp:include> 
												</td></tr>
											</tbody>
										</table>
									</div><!-- /.span -->
								</div><!-- /.row -->
								
		
		<div class="modal fade" id="uploadFileModal" tabindex="-1" role="dialog" aria-labelledby="uploadFileModalLabel" aria-hidden="true">
  			  <div class="modal-dialog">
   			     <div class="modal-content">
         			   <div class="modal-header">
         			   		   <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
             				   <h4 class="modal-title" id="myModalLabel">上传</h4>
          			  </div>
           			  <div class="modal-body">
           			  	<input id="uploadFile" name="uploadFile" type="file">
           			  </div>
            		  <div class="modal-footer">
                		  <button id="updateTestCloseBtn" type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                		  <button id="subjectStudentSaveBtn" type="button" class="btn btn-primary" data-dismiss="modal">保存</button>
            		</div>
       		 	</div><!-- /.modal-content -->
   			</div><!-- /.modal -->
		</div>
		
	</body>
</html>
